The Gooey Code Generator supports template files ("temFiles"). These templates are designed to provide all the hooks for the end user. Allow for more optimized code generation. And to allow the user to reformat the template files into thier own indenting method.
The template files fit into 3 categorys.
The first category is for the file named "Setup". This is the file that is presented to the user for code generation options.
The second category is for the file named "Links". This file is called like a subroutine from within the template files. This file generates the code for all the Gooey linkages, like pressing a button to open a window.
The last category is the templates for all the files to be generated. The standard naming convention is to prefix the files with "mm" if they generate Gooey private files (ones the user does not normally modify). The other files are the ones the user modifies (the ones with the Hook routines).
** Template selection.
The first thing to do after starting up the Gooey Code Generator is to select the Template folder for the language variation that you will be using. Either use the menu item for activating this selection (or Cmd-T ) or simply press on the Templates button (which is a button with documents overlapping each other).
Press the 'Select"xxx"' button at the bottom of the selection dialog. This will select the desired template folder. This folder preference will be saved for the next time the Gooey Code Generator is run.
Pressing "Open" will open the currently selected folder. It will not select it as the "Template" folder. You must press the button below the list area to select a template folder.
Next, select the menu item to enter your own unique copyright notice. If you do not enter one then the default copyright notice will be used. This string will be inserted by the Gooey Code Generator into the output files. Remember that this string will be placed on one line, not multiple lines. This information is kept in the preferences file for the next time this program is run.
Next, open the Gooey prototype that you have previously designed. This loads in the prototype that we will be generating code for. Either use the menu item for activating this selection or simply press on the Select Prototype button.
Next, start the code generation. Either use the menu item for activating this selection or simply press on the Generate Code button.
The "progress" bar across the bottom is actually a "File position" indicator. It is very useful when designing your template files, for seeing loops in the file. As the code is generated you will see it's progress thru each file. The short files will go by very fast, while the large files require more processing.
Messages of interest, and used to determine progress, are displayed in the text area toward the bottom of the window:
To close the current prototye, and to get ready to open another one, select the "Close" menu option:
To quit the Gooey Code Generator, simply select the "Quit" menu option:
** Setup file.
When the Gooey Code Generator is started up and a Template folder had previously been selected then it automatically opens the "Setup" file in that folder to present the user with the specific code generation options for those templates.
Now for an explaination of how this file is read and what it affects.
Before reading the "Setup" file the following defaults are initialized inside of the Code Generator:
a) The standard command delimiter is set to be '$'.
b) The file creator, for all files to be made except for the Rez file, is set to 'KAHL'. This is the default creator for THINK C and THINK C++.
c) The flag saying that we are doing Pascal is set to FALSE.
** TCL flag.
TCL (THINK Class Library) vs others. When the "Setup" file is read the name of the template folder is scanned. If the characters "TCL" are in the template folder name then a special flag is set to true. This flag tells the resource creation code that it should add the command IDs to each menu item name.
** File.
The first class of commands are 'File'. There is only one type in this class and that is 'Creator'.
Creator, e.g. $File.Creator = PJMM$, is used to change the file creator from the default of 'KAHL' (for THINK C) to something else (like PJMM for THINK Pascal). This makes all the text files created have the file creator that corresponds to the compiler/editor that needs to be opened when they are double-clicked on. The Type for all files will automatically be set to 'TEXT'.
** Code.
The next class of commands are 'Code'. There are two types in this class.
Delimiter, e.g. $Code.Delimiter = #$, changes the command delimiter from the default of '$' into a new character. This is commonly changed when the default character '$' has a normal use in the language the templates are for. For example, Pascal uses the '$' to specify hexidecimal characters. So, the default is changed for it's templates over to '#'.
Pascal, e.g. $Code.Pascal$, is used to flag the Code Generator that Pascal is being generated. This difference affects the type style definition. C uses numbers added together for different combinations of styles. Pascal uses a set definition that must have brackets enclosing then and separate them by commas instead of adding them together. So, for Pascal the type style may be [bold, underline]. For non Pascal, the type style will be bold + underline.
** Option.
The final class of commands for the "Setup" file are 'Option' commands. These commands always come in groups of 3 lines of information.
Where 'Option.Name' defines the conditional code generation name to be used in the templates. Only the first 8 characters of this name are used for matching, however the name can be longer than 8 characters.
'Option.Description' contains the message line to be displayed in the Gooey Code Generation options list. This name should say either to add or support some option.
'Option.Default' is defined to either be 'true' or 'false'. This is the default state that this option is displayed to the user as. For example, if the default is set to 'true' then this option is initially checked (selected) when the Gooey Code Generator is started up. If this default is set to 'false' then it is initially unchecked. It is best to set this default to the case more often used. The user can edit this file and easily change the default to be what they like the best.
Add your own conditional code generation options to this file. Define a Name to optionally add in your favorite code at areas that you seem to always add the same thing. Also, this can be used to add in support for something that you may be adding always yourself, like support for QuickTime. In this case you would add in the support code inside a conditional code generation statement.
** Template files.
Template files are organized to create both the files that Gooey uses to handle the interface and events for you, prefixed with 'mm' and the files that contain all the 'Hooks' to add in your additions. So, if a generated file starts with 'mm', like mmWMainWindow.c, then that file is a Gooey file that is not normally edited. If there is no prefix and it is not the 'Main' file, then that file is designed to contain all the hooks that you need to add in your own code.
Most Compilers also support the sources being in multiple folders. Where this is the case the Gooey files will be placed in a folder titled 'mm'. All other files will be in the 'u' folder.
There are two (2) types of commands in these template files. One type is flow control and condition checking. The other type is value and name substitution.
** Flow control and condition checking.
** Message.
"Message" sends a message to the Gooey Code Generator message line display. This is designed as a general progress and information message to the user. This message will also go out to the 'Generation Notes' file.
$$Message Text to the message
where: $Worksheet.name$ and $Prototype.name$ are allowed in the message. The $Prototype.name$ is the prototype name and is used for general files, like "Common". While $Worksheet.name$ is a worksheet specific name and is only valid inside a worksheet (Alert, Dialog, or Window) loop.
** Loop.
"Loop" first checks to see if there is anything to loop thru, for example if it is a loop for Alerts then it checks to see if any Alerts were designed in the prototype. If the condition is true, and there are items to loop thru then the code inside the "$$Loop xxx" and the "$$endLoop" statements will generate code. If the condition is false then no code is generated inside this "Loop". Remember that nested "Loop"s inherit a previous false condition from an "If" or "Loop", overriding thier potential true condition. So if an outside "if" is false then all "Loop"s inside it are also made to contain nothing to loop thru.
NOTE: A special check is done if the "Loop" command is the first line in a template file. If the condition is false, e.g. there were no Alerts designed in the Prototype file, then that whole template file is closed and skipped.
NOTE: Loops for Links are described in the "Links" file section.
Loop thru all Menu lists. This will loop thru standard menus only and not hierarchial menus.
$$Loop Menus
Loop thru all Hierarchial Menu lists. This will loop thru hierarchial menus only and not standardmenus.
$$Loop HierMenus
Loop thru all Menu items in the current menu. This loop should be used inside of either a "Menus" or "HierMenus" loop.
$$Loop MenuItems
Loop thru all popup menu items in the current control. While looping thru controls, and verifying that the current control is a popup, then use this loop to go thru all the popup menu items.
$$Loop PopupItems
Loop thru all palette items in the current control. While looping thru controls, and verifying that this control is a Palette, then use this loop to loop thru all possible palette selections.
$$Loop PaletteItems
Loop thru all radios in the current control's group. This is used in radio selection, to turn off all other radios in this radio group, when a specific radio is selected.
$$Loop RadioGroup
Loop thru all worksheets, only do Alerts.
$$Loop Alerts
Loop thru all worksheets, only do Modal & Modeless Dialogs. This loop is used where you handle Modal and Modeless dialogs the same way.
$$Loop Dialogs
Loop thru all worksheets, only do Modal Dialogs.
$$Loop ModalDialogs
Loop thru all worksheets, only do Modeless Dialogs and Movable Modal Dialogs ( which are usually Modeless Dialogs with an extra flag set).
$$Loop ModelessDialogs
Loop thru all worksheets, only do windows.
$$Loop Windows
Loop thru all Sounds.
$$Loop Sounds
Loop thru all controls in the current window or dialog.
$$Loop Controls
Loop for a specific control type only, the valid types are:
"endLoop" terminates the last "Loop" command. At this time the code generation flag takes on one of two states:
a) If this is the last item to loop thru then no loop back is performed and the code generation state returns to the previous "If" or "Loop" result (either true or false).
b) If this is not the last item to be looped thru then the loop returns to the line immediately following the "Loop" command and the next item is processed.
$$EndLoop End of a loop.
** File.
"File" is used to create an output file. It is placed as the first line of the template file for general code. It is usually the second or third line in template files that loop thru worksheet types, e.g. Alerts or dialogs or Windows. Two substitutions are allowed in these lines. One is for the prototype name, used to append to general file names. The other is the current worksheet name.
The file created is of type "TEXT" and creator "KAHL", unless the creator was changed in the "Setup" file.
$$File mm$Worksheet.name$.c
$$File MyFile_$Prototype.name$.c
** CloseFile.
"CloseFile" closes the currently open output file.
$$CloseFile
** Link.
"Link" first checks to see if there are any Gooey linkages designed in the prototype for the currently active object. If there are any then the "Links" file is opened and all linkages are found and the code generated for them.
Links to happen on the Open of a Window, Dialog, or Alert.
$$Link Worksheet.Open
Links to happen on the Close of a Window, Dialog, or Alert
$$Link Worksheet.Close
Links for an Activate of a Window or Modeless Dialog.
$$Link Worksheet.Activate
Links for a Deactivate of a Window or Modeless Dialog.
$$Link Worksheet.Deactivate
Do links for the current Menu Item.
$$Link Menu
Links for selected or pressed. E.g. Checking a checkbox, or pressing a button.
$$Link Control.Select
Links for deselected, for checkboxes and radios. E.g. Unchecking a checkbox.
$$Link Control.Deselect
** IF.
"If" first checks the condition. If the condition is true then the code inside the "$$If xxx" and the "$$endif" statements are generated. If the condition is false then no code is generated inside this "If". Remember that nested "If"s inherit a previous false condition, overriding thier potential true condition. So if an outside "if" or "Loop" is false then all "if"s inside it are also made false.
** If Option.
For user options
$$if Option.xxx
where xxx is the Name specified in the "Setup" file as an option name. Remember that the first 8 characters are actually used, even though the name can be longer than 8 characters.
** If Menu.
For use inside of a Menu loop.
$$if Menu.xxx
It is true if we are in the loop for that type ofmenu.
Apple Apple Menu
File File Menu
New 'New' item in the File Menu
Open 'Open...' item in the File Menu
Close 'Close' item in the File Menu
Save 'Save' item in the File Menu
SaveAs 'Save As...' item in the File Menu
Revert 'Revert to Saved' item in the File Menu
PageSetup 'Page Setup...' item in the File Menu
Paint 'Print...' item in the File Menu
Quit 'Quit' item in the File Menu
Edit Edit Menu
Undo 'Undo' item in the Edit Menu
Cut 'Cut' item in the Edit Menu
Copy 'Copy' item in the Edit Menu
Paste 'Paste' item in the Edit Menu
Clear 'Clear' item in the Edit Menu
SelectAll 'Select All' item in the Edit Menu
Font Font Menu
For use inside of a MenuItem loop. It is true if we are in the item named 'Quit'. Note that another check also has to be true, and that is that the Menu this item is in must be titled 'File'.
NOTE: For localization purposes, these names are kept in a 'STR#' resource inside of the Gooey Code Generator.
** If Worksheet.
For Windows, Dialogs, and Alerts
$$if Worksheet.xxx
This condition is true if the current worksheet looping thru has this attribute:
OpenAtStartup If designed to open at program startup.
Center Center window selected, Horz or Vert or Both.
CenterHorz Horz center window on screen.
CenterVert Vert center window on screen.
SavePosition Save window loc. from program open to open.
Document A document type window, with grow box.
Icons Has graphical icons in this window.
Pictures Has graphical pictures in this window.
Lists Has lists in this window.
EditLists Has EditText or lists in this window.
HotSpots Has HotRects in this window.
Sicns Has sicns in this window.
Palettes Has palettes in this window.
CheckboxesOrRadios Has checkboxes, radios, or toggle plugins.
HasCheckboxes Has checkboxes, radios, or toggle plugins.
HasControls If window has any controls at all.
Scrollbars If window has any scrollbars or gauge plugins.
ScrollHorz Horz scrollbar for document type window
ScrollVert Vert scrollbar for document type window
** If Alert.
$$if Alert.xxx
This condition is true if the current Alert looping thru has this attribute:
Stop Stop alert
Note Note alert
Caution Caution alert
** If ModelessDialog.
$$if ModelessDialog.xxx
This condition is true if the current Dialog looping thru has this attribute:
Zoomable Zoomable Modeless
Resizable Resizable Modeless
GoAway Has a GoAway box
Movable Movable modal dialog
If Window.
$$if Window.xxx
This condition is true if the current Window looping thru has this attribute:
Zoomable Zoomable window
Resizable Resizable window
GoAway Has a GoAway box
Floating Floating window
** These 3 checks are done on the whole prototype.
If HasZoomWindows.
$$if HasZoomWindows
If any windows in the prototype have zoom boxes.
If HasResizableWindows.
$$if HasResizableWindows
If any windows in the prototype are resizable.
If HasGoAwayBoxes.
$$if HasGoAwayBoxes
If any windows in the prototype have close boxes.
** If Control.Type.
This check is done on the current control we are looping thru.
These checks are done on the current control we are looping thru.
$$if Control.xxx
Default Default control, e.g. OK or Cancel outlined.
Graphic Graphic, not a button. For Icons, sicns, & Pictures.
NonGraphic Active button type, e.g. Picture used as button.
HotSpot For HotRect, says HotSpot is active.
Rectangle For HotRect, says HotSpot is inactive, a rectangle.
MultipleLine For StaticText, says TextBox call is to be used.
SingleLine For StaticText, says DrawString call is to be used.
ClipPicture For Picture, says clip picture instead of resize to fit.
ResizePicture For Picture, says resize picture to fit instead of clip.
UserString For HotRect, says a message string is used.
GrayLine For Line, says to draw the line in gray pattern.
SpecialText Flags text has nonstandard color, size, font, or style.
StandardText Flags text has standard color, size, font, or style.
Global Global, vs local, variable
Selected Checked or selected. For Checkbox, Radio, toggles.
Unselected Unchecked or unselected. For Checkbox, Radio, toggles.
Dimmed If initially dimmed.
ExitDialog Linkage, if ExitDialog was selected. For dialogs.
Plugin True if a plugin control.
HasLinks True if the control has linkages.
$$if Control.LineWidth ! 1
For Lines. Check for nonstandard size. '!' only allowed. Any size value can be checked against. This condition is true if the line width is not one (1) wide.
$$if Control.TextColor ! Black
Check for nonstandard color. '!' and 'Black' only allowed. This condition is true if the control's text color is not black.
$$if Control.TextSize ! 12
Check for nonstandard size. '!' only allowed. Any size value can be checked against, or 'Standard'. This condition is true if the text size is not set to 12 point.
$$if Control.TextFont ! System
Check for nonstandard font. '!' ,'Standard', 'applFont', and 'System' only allowed. This condition is true if the text font is not set to the system font.
$$if Control.TextStyle ! 0
Check for nonstandard style. '!', 'Standard', and '0' only allowed. This condition is true if the text style is not set to plain, e.g. NOT bold or underline, etc.
** EndIf.
"endif" terminates the last "if" command. At this time the code generation flag takes on one of two states:
a) If this is an outside and not nested "If" then code generation is true.
b) If this is a nested "If" then the code generation state returns to the previous "If" or "Loop" result (either true or false).
$$endif End of an IF
** Code.Delimiter.
"Code.Delimiter" is allowed in the template file. The normal use for it is to place one line immediately in front of the code line and another immediately after it. This would switch the delimiter to another character for only one line of code, the special code line that needs to generate this delimiter value as a normal character in a line of code.
$$Code.Delimiter = #
** Value and name substitution.
The commands listed in this section result in substitutions. What is substituted in may be a value, a name, or a string. The substitution may only be valid with in the proper context. For example, a control name substitution is only valid when inside of a control "Loop". Otherwise, the Gooey Code Generator does not know which control you want the name for.
When a "Unique name" is specified then that name will be only 'a' to 'z' and 'A' to Z' characters, all other characters are changed to '_'.
$CopyRight$
Copyright string, from dialog in Gooey. Be sure to select the Copyright menu item in the code generator before starting code generation.
$Date$
Current date string.
$Author$
Author name from Gooey personalization.
** Menu list
$Menu.xxx$
name Unique name for this menu.
FullName Full name for this menu, spaces and all.
ID Resource ID for this menu.
** Menu item
$MenuItem.xxx$
name Unique name for this menu item.
FullName Full name for this menu item, spaces and all.
ID Menu item id.
CmdID TCL Command ID for this menu.
** For Windows, Dialogs, and Alerts
$Worksheet.xxx$
name Unique name for this alert.
FullName Full name for this alert, spaces and all.
ID Resource ID for this worksheet.
RedBackColor Hex value for red of Window bkgd color
GreenBackColor Hex value for green of Window bkgd color
BlueBackColor Hex value for blue of Window bkgd color
LeftPosition Integer for Left edge of Window.
TopPosition Integer for Top edge of Window.
RightPosition Integer for Right edge of Window.
BottomPosition Integer for Bottom edge of Window.
Layer Integer for window floating layer.
$Sound.xxx$
name Unique name for this Sound.
FullName Full name for this Sound, spaces and all.
ID Resource ID for this Sound.
$Prototype.xxx$
name Unique name for this project.
$Control.xxx$
name Unique name for this control.
FullName Full name for this control, spaces and all.
RedTextColor Hex value for red portion of the Text color
GreenTextColor Hex value for green portion of the Text color
BlueTextColor Hex value for blue portion of the Text color
TextSize Integer value for Text size.
TextFont Integer or string name for font.
TextStyle String name list for style combinations.
TextAlignment String , e.g. teForceLeft, teJustRight, etc.
LeftPosition Integer for Left edge of control.
TopPosition Integer for Top edge of control.
RightPosition Integer for Right edge of control.
BottomPosition Integer for Bottom edge of control.
Active String 'true' if not dimmed, else 'false'.
LineWidth Integer for line width.
ShadowWidth Integer for shadow line width.
ItemID Integer, the DITL ID for Alerts and Dialogs
StringID Integer, the STR ID for the attached string.
MakeHotSpot Boolean, true for HotSpot, false for rectangle.
ID Integer, the CNTL ID for the control.
PopupID Integer, the Menu popup item field, while looping on PopupItems
NumColumns Integer, number columns in the palette.
HMethod Integer, palette hilite method.
Value Integer, initial value.
MinScroll Integer, scrollbar min value.
MaxScroll Integer, scrollbar max value.
StepScroll Integer, scrollbar arrow step size.
PageScroll Integer, scrollbar page step size.
MenuID Integer, menu resource ID for popup menu
NormalID Integer, Attached icon, etc., ID for normal.
HilitedID Integer, Attached icon, etc., ID for hilighted.
** Links file.
This file is called like a subroutine whenever a linkage in a window or control is found. It then walks thru all linkages for that item and generates the code for them.
These links are for opening and closing other windows, dialogs and alerts. Then inside these loops the window to be opened is the active window.
$$Loop Link.Open
$$Loop Link.Close
Sound linkages. The first is simply to the toolbox SysBeep call. The second has to do with playing a sound resource.
$$Loop Link.SysBeep
$$Loop Link.Sound
Enable or disable a specific menu list.
$$Loop Link.MenuEnable
$$Loop Link.MenuDisable
Enable or disable a specific menu item.
$$Loop Link.ItemEnable
$$Loop Link.ItemDisable
Check or uncheck a menu item. The previous checked or unchecked state is not looked at.
$$Loop Link.ItemCheck
$$Loop Link.ItemUncheck
Toggle a menu item from checked to unchecked or other way. The menu item is first looked at and then it is decided to check or uncheck it.
$$Loop Link.ItemToggle
This link should open the system Page Setup dialog.
$$Loop Link.PageSetup
This link should open the system Print dialog and start the printing process.
$$Loop Link.Print
This link should open the Standard File selection dialog.
$$Loop Link.FileOpen
This link should open the Standard File save dialog.
$$Loop Link.FileSave
This link should open the custom volume selection dialog.
$$Loop Link.VolumeSelect
These links are for controls. Then inside these loops the control to be operated on is the active control.
Check a checkbox or plugin toggle.
$$Loop Link.Check
Uncheck a checkbox or plugin toggle.
$$Loop Link.Uncheck
Select a radio. Remember to turn off all other radios in that group.
$$Loop Link.Radio
Hide a control.
$$Loop Link.Hide
Show a control.
$$Loop Link.Show
Dim, disable, a control.
$$Loop Link.Dim
Undim, enable, a control.
$$Loop Link.Undim
Hints ** ** ** ** ** ** ** ** ** ** ** **
The best way to study how these commands all work is to modify a template file and see how the changes you make affect the output code.
To make it easier and faster you should make a test folder and copy one template file into that folder. You will then be able to see the resultant code very fast.